﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Domain.ActiveDirectory.Model;

namespace WebUI.Models
{
    public class GroupViewModel
    {
        public string Name { get; set; }
        public HtmlString NamesOfMembers { get; set; }
        public List<MemberViewModel> Members { get; set; }

        public GroupViewModel(Group group)
        {
            Name = group.Name;
            Members = new List<MemberViewModel>();
            foreach (var memberName in group.MemberNames) 
            {
                Members.Add(new MemberViewModel() { Name = memberName, GroupName = Name });
            }
            StringBuilder memberNames = new StringBuilder();
            foreach (string s in group.MemberNames) {
                memberNames.Append(s);
                memberNames.Append("<br />");
            }
            NamesOfMembers = new HtmlString(memberNames.ToString());
        }
    }
}